import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { BaseEntity } from './BaseEntity';
import { SysDict } from './SysDict';

@Entity()
export class SysDictDetail extends BaseEntity {
  @Column({
    type: 'varchar',
    comment: '展示标签'
  })
  label: string;

  @Column({
    type: 'varchar',
    comment: '展示值（默认都是string）'
  })
  value: string;

  @Column({
    type: 'varchar',
    comment: '值得类型',
    // enum: ['string', 'boolean', 'int', 'float', 'json', 'empty'],
    default: 'string'
  })
  type: string;

  @Column({
    default: false,
    type: 'boolean',
    comment: '是否禁用'
  })
  disabled: boolean;

  @Column({
    type: 'int',
    comment: '排序'
  })
  sort: number;

  @Column({
    default: false,
    type: 'boolean',
    comment: '是否隐藏该项'
  })
  hide: boolean;

  /**
   * 备注
   *
   * @type {string}
   * @memberof User
   */
  @Column({ nullable: true, comment: '备注', type: 'varchar' })
  remark: string;

  @ManyToOne(() => SysDict, {
    onDelete: 'CASCADE',
    nullable: true
  })
  @JoinColumn({
    name: 'dict_id'
  })
  dict: SysDict;
}
